 define(['zepto','common','layer','mylayer','echo'], function ($,md_common,layer,mylayer,echo) {
	var app={
		//事件
		init:function(){
			echo.init({ offset: 100, throttle: 250 });
			$('.showDetail').off("click").on("click",function(){
				var id=$(this).attr("data-id");
				var title=$(this).attr("data-name");
				var lay=md_common.showLoad(false,false);
				$.postAjax("/blog/"+id,{},function(result){
					if(result.data){
						layer.close(lay);
						mylayer.showLayer({
			           		title:title,
			           		content:result.data,
			           		success:function(){
			           			
			           		},
			           		url:"/blog/"+id
			           });
					}
				})
			});
			$(".interact").off("click").on("click",function(){
				var id=$(this).attr("data-id");
				var t=$(this).attr("t");
				var that=this;
				$.postAjax("/post/interact",{'t':t,'id':id},function(rst){
					if(rst.code=="0x00000"){
						var interact_value=$(that).find(".text");
						var value=parseInt(interact_value.html())?parseInt(interact_value.html()):0;
						interact_value.html(value+1);
						$(that).addClass('is_interact');
					}
					else if(rst.code=="0x00003"){
						var interact_value=$(that).find(".text");
						var value=parseInt(interact_value.html())?parseInt(interact_value.html()):0;
						if(value>0){
							interact_value.html(value-1);
							$(that).removeClass('is_interact');
						}
					}
					else{
						if(rst.result){
							mylayer.showMessage(rst.result);
						}
						if(rst.code=="0x00002"){
							$(that).addClass('is_interact');
						}
					}
				});
			});
		}
	};
	return app;
});
